#include "RenderStairsSouth.h"
#define SCALE 4
#define HEIGHT 4

RenderStairsSouth::RenderStairsSouth(float init_red, float init_green, float init_blue)
{
	r = init_red; g = init_green; b = init_blue;
	//glEnable(GL_TEXTURE_2D);
	loadOpenGL2DTextureBMP("floor.bmp", &floor_texture, GL_RGB);
	
	//glBindTexture(GL_TEXTURE_2D, floor_texture);
	//glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); //GL_NEAREST or GL_LINEAR
    //glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); //GL_NEAREST or GL_LINEAR
	
	//glEnable(GL_TEXTURE_2D);
}

RenderStairsSouth::~RenderStairsSouth(void)
{
}

void RenderStairsSouth::draw(float init_x, float init_y, float init_z)
{
	x = (init_x * SCALE);
	y = (init_y * SCALE);
	z = (init_z * SCALE);

	GLfloat mat_ambient[] = { 0.2, 0.2, 0.2, 1};
	GLfloat mat_diffuse[] = { 0.2, 0.2, 0.2, 1 };
	GLfloat mat_specular[] = { 0.2, 0.2, 0.2, 1 };

	glPushMatrix();

	//	/* Set up material properties. */
	glEnable(GL_TEXTURE_2D);
	glTranslatef(x, y, z);
	glColor3f(1, 1,1); 
	glScalef(1.0, 1.0, 0.2);
	glBindTexture(GL_TEXTURE_2D, floor_texture); 	
	glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient);
	glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);
	glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
	glMaterialf(GL_FRONT, GL_SHININESS, 100.0 ); /* No effect if specular == 0 */
	//glutSolidCube(SCALE);

		//START THE QUADS!
		glBegin(GL_QUADS);

			glTexCoord2f(0.0, 0.0); glVertex3f(0.0, 0.0, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(SCALE, 0.0, 0.0);
			glTexCoord2f(1.0, 1.0); glVertex3f(SCALE, SCALE, 0.0);
			glTexCoord2f(1.0, 0.0); glVertex3f(0.0, SCALE, 0.0);

			glTexCoord2f(0.0, 0.0); glVertex3f(0.0, 0.0, SCALE);
			glTexCoord2f(0.0, 1.0); glVertex3f(SCALE, 0.0, SCALE);
			glTexCoord2f(1.0, 1.0); glVertex3f(SCALE, SCALE, SCALE);
			glTexCoord2f(1.0, 0.0); glVertex3f(0.0, SCALE, SCALE);

			glTexCoord2f(0.0, 0.0); glVertex3f(0.0, 0.0, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(0.0, 0.0, SCALE);
			glTexCoord2f(1.0, 1.0); glVertex3f(SCALE, 0.0, SCALE);
			glTexCoord2f(1.0, 0.0); glVertex3f(SCALE, 0.0, 0.0);

			glTexCoord2f(0.0, 0.0); glVertex3f(0.0, SCALE, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(0.0, SCALE, SCALE);
			glTexCoord2f(1.0, 1.0); glVertex3f(SCALE, SCALE, SCALE);
			glTexCoord2f(1.0, 0.0); glVertex3f(SCALE, SCALE, 0.0);

			glTexCoord2f(0.0, 0.0); glVertex3f(0.0, SCALE, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(0.0, SCALE, SCALE);
			glTexCoord2f(1.0, 1.0); glVertex3f(0.0, 0.0, SCALE);
			glTexCoord2f(1.0, 0.0); glVertex3f(0.0, 0.0, 0.0);

			glTexCoord2f(0.0, 0.0); glVertex3f(SCALE, SCALE, 0.0);
			glTexCoord2f(0.0, 1.0); glVertex3f(SCALE, SCALE, SCALE);
			glTexCoord2f(1.0, 1.0); glVertex3f(SCALE, 0.0, SCALE);
			glTexCoord2f(1.0, 0.0); glVertex3f(SCALE, 0.0, 0.0);

		glEnd();

	glTranslatef(-x, -y, -z);
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();

	glFlush();

}